package nirvana.core.validation.constraint;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import nirvana.core.validation.annotions.EnumNotEmpty;

import java.util.Objects;

/**
 * EnumNotEmptyValidator
 *
 * @author linkanyway
 * @version 1.0
 * @date 2024/01/28 20:36
 */
public class EnumNotEmptyValidator implements ConstraintValidator<EnumNotEmpty, Enum<?>> {

    @Override
    public void initialize(EnumNotEmpty constraintAnnotation) {
        ConstraintValidator.super.initialize (constraintAnnotation);
    }

    @Override
    public boolean isValid(Enum<?> value, ConstraintValidatorContext context) {
        return !Objects.isNull (value);
    }
}
